<script lang="ts" setup>
import { RouterView } from 'vue-router'
import zhCN from 'ant-design-vue/es/locale/zh_CN'
import enUS from 'ant-design-vue/es/locale/en_US'
import dayjs from 'dayjs'
import 'dayjs/locale/zh-cn'
import { getLanguage } from '@/plugins/i18n'
import ws from './utils/socket/WebSocket'

dayjs.locale('zh-cn')

const locale: any = ref(getLanguageType())

function getLanguageType() {
  const language = getLanguage()
  if (language == 'zh') {
    return zhCN
  } else if (language == 'en') {
    return enUS
  } else {
    return zhCN
  }
}

onMounted(() => {
  ws.connect()

  setTimeout(() => {
    ws.sendJson({
      content: '312312312',
      toUserId: 2
    })
  }, 2000)
})

const themeStore = useThemeStoreHook()
const themeToken = useThemeStoreHook().getThemeToken()
</script>

<template>
  <a-config-provider
    :locale="locale"
    :theme="{
      token: {
        colorPrimary: '#615ced'
      },
      algorithm: themeStore.getByTypeTheme(themeStore.themeType)
    }"
  >
    <RouterView />
    <SpDialog />
  </a-config-provider>
</template>

<style>
html,
body {
  overflow-x: hidden;
  height: 100%;
  margin: 0;
  padding: 0;
}
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

a {
  text-decoration: none;
}

li {
  list-style: none;
}

/* 针对所有元素的滚动条 */
::-webkit-scrollbar {
  width: 8px; /* 滚动条宽度 */
  height: 8px;
  z-index: 999999;
}

::-webkit-scrollbar-track {
  background: v-bind(themeToken.colorBorderSecondary);
  border-radius: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgb(219, 219, 219);
  border-radius: 10px;
}

/* 关闭默认动画 */
::view-transition-new(root),
::view-transition-old(root) {
  /* 关闭默认动画，否则影响自定义动画的执行 */
  animation: none !important;
  z-index: 99999 !important;
}
.dark::view-transition-old(root) {
  z-index: 1000000 !important;
}
</style>
